#ifndef __BSP_H
#define	__BSP_H

#include <stm32f10x.h>

#define SENDBUF_SIZE              64     // DMA发送缓冲区大小
#define H                         0.02f  // 控制周期
#define CALIB_MAXSPEED            100    // 校准时的最大速度

#define MOTOR_PWM_PORT            GPIOA
#define MOTOR_PWM_PIN             0x003F
#define MOTOR_DIR_PORT            GPIOC
#define MOTOR_DIR_PIN             0xC00F
#define SENSOR_PORT               GPIOD
#define SENSOR_PIN                0x01BC
#define ADC_PORT                  GPIOA
#define ADC_PIN                   0x0040
#define ADC_CHANNEL               ADC_Channel_6
#define LED_PORT                  GPIOC
#define LED_PIN                   GPIO_Pin_13
#define LED_OFF                   LED_PORT->BSRR=LED_PIN
#define LED_ON                    LED_PORT->BRR=LED_PIN
#define MOTOR_PWM_OUTPUT_LOW(i)   MOTOR_PWM_PORT->BRR=MotorPwmPin[i]
#define MOTOR_PWM_OUTPUT_HIGH(i)  MOTOR_PWM_PORT->BSRR=MotorPwmPin[i]
#define MOTOR_DIR_OUTPUT_LOW(i)   MOTOR_DIR_PORT->BRR=MotorDirPin[i]
#define MOTOR_DIR_OUTPUT_HIGH(i)  MOTOR_DIR_PORT->BSRR=MotorDirPin[i]

#define PRESS_MIN	20
#define PRESS_MAX	6000
#define VOLTAGE_MIN 150
#define VOLTAGE_MAX 3300

typedef unsigned char u8;
typedef unsigned short u16;
typedef short int s16;

extern const u16 MotorPwmPin[6];
extern const u16 MotorDirPin[6];
extern const u16 SensorPin[6];

void BSP_Init(void);
void DMA_Enable(void);
void DMA_Buffer_Stuff(u8 *Data,u8 len);
void DMA_Buffer_Clear(void);
u16 Get_Adc(void);

#endif
